﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using YLPublicService.TransferModel;
using YLPublicService.EnumExtension;

using YLServiceCLient.YLAdminClient;
using YLServerInterface.UserControls;

namespace YLServerInterface.NavigateWindows
{
    /// <summary>
    /// Interaction logic for UserItemsPage.xaml
    /// </summary>
    public partial class UserItemsPage : Page
    {

        UserItemsPage()
        {
            InitializeComponent();
        }
        public UserItemsPage(IEnumerable<WorkItem2ServerUser> items)
            : this()
        {
            this.items = items;
            initItems(items);
        }
        void initItems(IEnumerable<WorkItem2ServerUser> items)
        {
            lstItems.Items.Clear();
            if (items == null)
            {
                return;
            }
            foreach (var item in items)
            {
                lstItems.Items.Add(new Item(item));
            }
        }
        /// <summary>
        /// 传入的items 
        /// </summary>
        IEnumerable<WorkItem2ServerUser> items;
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            WorkItemStatus parsedStatus;
            var hasStatus = (cmbShowDataType.SelectedValue as ComboBoxItem)
               .Content.ToString().TryEnumMemberValueToEnum<WorkItemStatus>(out parsedStatus);
            if (hasStatus == false)
            {
                return;
            }
            var newItems = items.Where(i => i.Status == parsedStatus);
            initItems(newItems);
        }
        private void CommandBinding_Executed_1(object sender, ExecutedRoutedEventArgs e)
        {
            //frmImageOp imgOp = new frmImageOp();
            //imgOp.DataContext = (e.OriginalSource as Button).DataContext;
            //NavigationService.Navigate(imgOp);
            Forms.testDownLoadFiles frm = new Forms.testDownLoadFiles();
            frm.Tag = (e.OriginalSource as Button).DataContext;
            frm.ShowDialog();
        }
    }
}
